package com.settlement.system.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.settlement.system.common.base.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 拼多多保证金明细
 * </p>
 *
 * @author huangrensen
 * @since 2024-05-28
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PddDeposit extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId(value = "id")
    private String id;


    /**
     * 店铺ID
     */
    private Long storeId;
    @TableField(exist = false)
    private String storeName;


    /**
     * 入账时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime billTime;


    /**
     * 账户类型
     */
    private String accountType;


    /**
     * 账务类型
     */
    private String billType;


    /**
     * 收入金额（+元）
     */
    private BigDecimal incomeAmount;


    /**
     * 支出金额（-元）
     */
    private BigDecimal payAmount;


    /**
     * 备注
     */
    private String remark;


    /**
     * 业务描述
     */
    private String businessRemark;

    @TableField(exist = false)
    private String tableName;
    @TableField(exist = false)
    private String billMonth;

    // 截取长度超出范围的字段
    public void cutString() {
        if (this.businessRemark != null && this.businessRemark.length() > 2000) {
            this.businessRemark = this.businessRemark.substring(0, 2000);
        }
        if (this.remark != null && this.remark.length() > 2000) {
            this.remark = this.remark.substring(0, 2000);
        }
    }
}
